from utils.api_util import Session


class LookOrderAction:
    '''
    查看订单操作类
    '''
    session = Session.get_session()

    def do_query_by_parkingid(self, data):
        '''
        完成向接口发送请求
        '''
        url = data['url']
        params = data['params']
        resp = self.session.get(url=url, params=params)
        return resp

    def success_or_failed(self,resp):
        '''
        根据响应内容判断查询实际结果为success或failed
        '''
        # resp = resp.replace("null","1")
        # resp = eval(resp)
        if 'total' not in resp:
            return 'failed'
        else:
            return 'success'
        # ls = DBConnection.query(sql='')
